package com.hainingtong.core.handler;

import com.hainingtong.core.util.Result;
import com.hainingtong.core.util.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
@Slf4j
public class AuthorizationExceptionExceptionHandler {

    @ExceptionHandler
    @ResponseBody
    public Result ErrorHandler(AuthorizationException e) {
        log.error("没有通过权限验证！", e);
        return Result.error(ResultCode.NO_PERMISSION);
    }

    @ExceptionHandler
    @ResponseBody
    public Result ErrorHandler1(ArithmeticException e) {
        log.error("未登录！", e);
        return Result.error(ResultCode.NOT_AUTH);
    }
}

